package com.two.screen.water.balance.adapter;

import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ArrayAdapter;
import android.widget.TextView;

import com.two.screen.water.balance.R;
import com.two.screen.water.balance.bean.BaseData;

import java.util.ArrayList;

public class TestArrayAdapter extends ArrayAdapter<BaseData> {
    private Context mContext;
    private ArrayList<BaseData> mList;

    public TestArrayAdapter(Context context, ArrayList<BaseData> list) {
        super(context, android.R.layout.simple_spinner_item, list);
        mContext = context;
        mList = list;
    }

    @Override
    public View getDropDownView(int position, View convertView, ViewGroup parent) {
        //修改Spinner展开后的字体颜色
        if (convertView == null) {
            LayoutInflater inflater = LayoutInflater.from(mContext);
            convertView = inflater.inflate(R.layout.simple_spinner_dropdown_item, parent, false);
        }

        //此处text1是Spinner默认的用来显示文字的TextView
        TextView tv = (TextView) convertView.findViewById(android.R.id.text1);
        tv.setText(mList.get(position).getName());
        //tv.setTextSize(mContext.getResources().getDimension(R.dimen.common_measure_15sp));
        //tv.setTextColor(Color.RED);

        return convertView;

    }

    @Override
    public View getView(int position, View convertView, ViewGroup parent) {
        // 修改Spinner选择后结果的字体颜色
        if (convertView == null) {
            LayoutInflater inflater = LayoutInflater.from(mContext);
            convertView = inflater.inflate(R.layout.simple_spinner_item, parent, false);
        }

        //此处text1是Spinner默认的用来显示文字的TextView
        TextView tv = (TextView) convertView.findViewById(android.R.id.text1);
        tv.setText(mList.get(position).getName());
        //tv.setTextSize(mContext.getResources().getDimension(R.dimen.common_measure_24sp));
        //tv.setTextColor(Color.BLUE);
        return convertView;
    }

}